#ifndef _DRV_ADS1115_H
#define _DRV_ADS1115_H

#include "stdint.h"
#include "soft_i2c.h"


#define ADS1115_OS 0x01
#define ADS1115_MUX 0x04
#define ADS1115_PGA 0x01
#define ADS1115_MODE 0x01
#define ADS1115_DR 0x04
#define ADS1115_COMP_MODE 0x00
#define ADS1115_COMP_POL 0x00
#define ADS1115_COMP_LAT 0x00
#define ADS1115_COMP_QUE 0x03

#define ADS1115_Config_MSB (ADS1115_OS << 7) | (ADS1115_MUX << 4) | (ADS1115_PGA << 1) | ADS1115_MODE
#define ADS1115_Config_LSB (ADS1115_DR << 5) | (ADS1115_COMP_MODE << 4) | (ADS1115_COMP_POL << 3) | (ADS1115_COMP_LAT << 2) | ADS1115_COMP_QUE

#define ADS1115_Lo_thresh 0x8000
#define ADS1115_Hi_thresh 0x7FFF


#define ADS1115_REG_Conversion 0x00
#define ADS1115_REG_Config 0x01
#define ADS1115_REG_L_thresh 0x02
#define ADS1115_REG_R_thresh 0x03

#define ADS1115_BASE_VAL    (4.096)


void ADS1115_config(soft_i2c_driver *soft_i2c_driver, uint8_t channel);

uint16_t ADS1115_ReadADC(soft_i2c_driver *soft_i2c_driver);
void ADS1115_ReadAllChannel(soft_i2c_driver *soft_i2c_driver, uint16_t data[]);

void ADS1115_VolConversion(float *vol_value,int16_t data[4],float base_vol);
#endif
